package org.yourscrum.domain;

privileged aspect ProjectDataOnDemand_Roo_DataOnDemand {
    
    declare @type: ProjectDataOnDemand: @org.springframework.stereotype.Component;    
    
    private java.util.Random ProjectDataOnDemand.rnd = new java.security.SecureRandom();    
    
    private java.util.List<org.yourscrum.domain.Project> ProjectDataOnDemand.data;    
    
    public org.yourscrum.domain.Project ProjectDataOnDemand.getNewTransientProject(int index) {    
        org.yourscrum.domain.Project obj = new org.yourscrum.domain.Project();        
        obj.setDescription("description_" + index);        
        obj.setTitle("title_" + index);        
        return obj;        
    }    
    
    public org.yourscrum.domain.Project ProjectDataOnDemand.getRandomProject() {    
        init();        
        return data.get(rnd.nextInt(data.size()));        
    }    
    
    public boolean ProjectDataOnDemand.modifyProject(org.yourscrum.domain.Project obj) {    
        return false;        
    }    
    
    @org.springframework.transaction.annotation.Transactional(propagation = org.springframework.transaction.annotation.Propagation.REQUIRES_NEW)    
    public void ProjectDataOnDemand.init() {    
        if (data != null) {        
            return;            
        }        
                
        data = org.yourscrum.domain.Project.findProjectEntries(0, 10);        
        if (data == null) throw new IllegalStateException("Find entries implementation for 'Project' illegally returned null");        
        if (data.size() > 0) {        
            return;            
        }        
                
        for (int i = 0; i < 10; i++) {        
            org.yourscrum.domain.Project obj = getNewTransientProject(i);            
            obj.persist();            
            data.add(obj);            
        }        
    }    
    
}
